﻿<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Members" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="~/UserControls/LoginBanner.ascx" %>
<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="~/UserControls/ImageThumbnail.ascx" %>
<%@ Register TagPrefix="Club" TagName="WebContent" Src="~/UserControls/WebContent.ascx" %>

<script runat="server">

    Protected Sub hp1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Filter = CType(sender, LinkButton).Text
        MemDataSource.SelectParameters(0).DefaultValue = Filter
    End Sub
    
    Private m_filter As String
    Property Filter() As String
        Get
            If m_filter Is Nothing Then
                Dim o As Object = ViewState("Filter")
                If Not o Is Nothing Then
                    m_filter = CStr(o)
                Else
                    m_filter = ""
                End If
            End If
            Return m_filter
        End Get
        Set(ByVal value As String)
            ViewState("Filter") = value
        End Set
    End Property
    
    Function linkClass(ByVal letter As String) As String
        If letter = Filter Then
            Return "selectedLetter"
        Else
            Return ""
        End If
    End Function

    Protected Sub showall_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Filter = ""
        MemDataSource.SelectParameters(0).DefaultValue = Filter
    End Sub
    
    Public Function PreFormat(ByVal content As String) As String
        If Not content Is Nothing Then
            Return content.Replace(vbCrLf, "<br/>")
        Else
            Return Nothing
        End If
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If User.IsInRole("Administrators") = True Then
            manageusers.Visible = True
            sendemail.Visible = True
        Else
            manageusers.Visible = False
            sendemail.Visible = False
        End If
    End Sub
    
    Public Shared Function ShowEmail(ByVal provkey As Object) As String
        If provkey Is Nothing = False Then
            Try
                Return Membership.GetUser(provkey).Email()
            Catch ex As Exception
                Return ""
            End Try
        Else
            Return ""
        End If
    End Function
    
    
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="body">
        <Club:LoginBanner ID="LoginBanner1" runat="server" />
        <div id="columnleft">
            <a name="content_start" id="content_start"></a>
            <div class="leftblock">
            <Club:WebContent ID="WebContent1" runat="server" Section="memberlist" />
                
                    <Club:RolloverLink ID="edit" runat="server" NavigateURL="~/member/details.aspx" Text="My Details" />
                    <br />
                    <Club:RolloverLink ID="manageusers" runat="server" NavigateURL="~/admin/ManageUsers.aspx" Text="Manage Users" />
                    <Club:RolloverLink runat="server" id="sendemail" text="Send Email" NavigateURL="~/Admin/Email.aspx" />
                    
            </div>
        </div>
        <div id="columnright">
            <div class="rightblock">
                &nbsp;<asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel id="UpdatePanel1" runat="server"><contenttemplate>
                    <asp:LinkButton ID="showall" runat="server" Text="Show All" OnClick="showall_Click" />
                        <asp:ObjectDataSource id="LetersDataSource" runat="server" SelectMethod="ReturnLettersCount" TypeName="ClubStarterKit.Web.Members"></asp:ObjectDataSource>
                    <asp:Repeater DataSourceID="LetersDataSource" ID="Repeater1" runat="server">
                        <ItemTemplate>
                            <asp:LinkButton ID="hp1" runat="server" Text='<%#Eval("letter")%>' Visible='<%# CInt(Eval("num"))>0 %>'
                                OnClick="hp1_Click" CssClass='<%# LinkClass(CSTR(EVAL("letter")))%>' />
                            <asp:Label ID="LinkButton1" runat="server" Text='<%#Eval("letter")%>' Visible='<%# CInt(Eval("num"))=0 %>' />
                        </ItemTemplate>
                    </asp:Repeater>
                <div class="dashedline">
                    &nbsp;</div>
                    <asp:ObjectDataSource ID="MemDataSource" runat="server" SelectMethod="Getmembers"
                        TypeName="ClubStarterKit.Web.Members">
                        <SelectParameters>
                            <asp:Parameter Name="Filter" DefaultValue="" Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                <asp:DataList ID="DataList1" runat="server" DataSourceID="MemDataSource" RepeatColumns="2"
                    RepeatDirection="Horizontal">
                    <ItemTemplate>
                        <div class="membercard">
                           <div style="float: left; padding: 0 5px 0 0;">
                                <asp:image ID="ImageThumbnail1" runat="server" imageURL='<%# "~\UserControls\AvatarImagefetch.ashx?Memberid=" & Eval("memberid").ToString() %>' />
                                    
                            </div>
                            <h3>
                                <asp:Label ID="titleLabel" runat="server" Text='<%# Cstr(Eval("FirstName")) & " " &  Cstr(Eval("LastName"))  %>' />
                            </h3>
                            <p>
                                <asp:HyperLink ID="emailLink" runat="server" NavigateUrl='<%# "mailto:" & ShowEmail(Eval("memberid"))%>'
                                    Text='<%# Shared_Routines.truncate(ShowEmail(Eval("memberid")), 28) %>' />
                            </p>
                            <p>
                                <asp:Label ID="addressLabel" runat="server" Text='<%# preformat(Cstr(Eval("Address"))) %>' />
                            </p>
                            <p>
                                Phone:
                                <asp:Label ID="phonelabel" runat="server" Text='<%# Eval("Phone")%>' />
                            </p>
                            <div class="clearcard"></div>
                        </div>
                    </ItemTemplate>
                </asp:DataList>
            </contenttemplate>
        </asp:UpdatePanel>
                <asp:UpdateProgress id="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <progresstemplate>
                        <asp:Image ID="Image2" runat="server" SkinID="loading" />
                    </progresstemplate>
                </asp:UpdateProgress>
            </div>
        </div>
        <div class="clear2column"></div>
    </div>
</asp:Content>
